package com.jinlejia.erp.utils;

import java.io.File;
import java.util.ArrayList;

/**
 * 文件夹遍历
 *
 * @author once
 */
public class DirTraversal {

    //recursion
    public static ArrayList<String> listFiles(String strPath) {
        return refreshFileList(strPath);
    }

    public static ArrayList<String> refreshFileList(String strPath) {
        ArrayList<String> filelist = new ArrayList<>();
        File dir = new File(strPath);
        File[] files = dir.listFiles();

        if (files == null)
            return new ArrayList<>();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                refreshFileList(files[i].getAbsolutePath());
            } else {
                filelist.add(files[i].getAbsolutePath());
            }
        }
        return filelist;
    }
}
